/*
 * Copyright (c) 2019 Nanjing Wind Information Co., Ltd. All Rights Reserved;
 * @Package wind.autotest.service
 * @version 1.0.0
 * @Date 2019年4月11日
 * @author jlliu.Farrior@wind.com.cn
 */
package wind.autotest.service.frontend;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import wind.autotest.dao.TestTaskDAO;
import wind.autotest.pojo.TestTask;
import wind.autotest.util.Page4Navigator;

/**
 * @Description: <类功能描述>
 * @author jlliu.Farrior@wind.com.cn
 * @Date 2019年4月11日 下午5:43:03
 * 
 */
@Service
public class TestTaskService {

	@Autowired
	private TestTaskDAO testTaskDAO;


	public Page4Navigator<TestTask> list(int start, int size, int navigatePages) {
		Sort sort = new Sort(Sort.Direction.DESC, "id");
		Pageable pageable = new PageRequest(start, size,sort);
		Page<TestTask> pageFromJPA =testTaskDAO.findAll(pageable);
		return new Page4Navigator<>(pageFromJPA,navigatePages);
	}
	public List<TestTask> list() {
    	Sort sort = new Sort(Sort.Direction.DESC, "id");
		return testTaskDAO.findAll(sort);
	}

	public void add(TestTask bean) {
		testTaskDAO.save(bean);
	}

	public void delete(int id) {
		testTaskDAO.delete(id);
	}

	public TestTask get(int id) {
		TestTask task= testTaskDAO.findOne(id);
		return task;
	}
	public void update(TestTask bean) {
		testTaskDAO.save(bean);
	}

}
